<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .container , .child{
            border: solid 1px red;
             border-radius: 10px;
             cursor: pointer;

        }

        .container{
            width: 300px;
            height: 300px;
            position: relative;
            background: #000;
            
        }

        .child{
            width: 200px;
            height: 200px;
            position: absolute;
            top: 50px;
            left: 50px;
            background-color: skyblue;
        }


    </style>
</head>
<body>


    <button  onclick="alert('点我干啥')">点我</button>

    <input type="text" onkeydown="keyDown()">
    
    <a href="http://www.baidu.com" onclick="clickHref()">点我跳转</a>



    <div class="container" onclick="clickContainer()">

        <div class="child" onclick="clickChild()">



        </div>


    </div>










    <script>
        function keyDown(){
            const event = window.event;
            console.log("event",event);
            
        }


        function clickHref (){
            //希望阻止 超链接的 默认行为
            const event = window.event;
            event.preventDefault();


            console.log("超链接被点击");
        }


        function  clickContainer(){
            console.log("父容器被点击....");
        }

        function clickChild(){
            //阻止事件冒泡 
            const event = window.event;
            event.stopPropagation();
             console.log("子元素被点击....");
        }


    </script>
</body>
</html>